package com.lorianknights.rpg.managers
{
	
	import com.lorianknights.rpg.interfaces.IManager;
	import com.lorianknights.rpg.utils.Constants;
	
	public class Manager extends Object implements IManager
	{
		
		private var _isManager:Boolean = false;
		private var _mng:Manager;
		private var  _managerData:Object = null;
		public static var managerDataClasses:Array = [Constants.MANAGERS[0], Constants.MANAGERS[1], Constants.MANAGERS[2]];
		
		public function Manager(data:Object = null)
		{
			
			super();
			managerData = data;
			
				if (this._mng != null)
				{
					
					throw new Error("Use Manager.getInstance(), instead of the 'new' keyword for instantiation purposes");
					
				}
				
					if (data == null)
					{
						
						this.managerData = [ { mngData: this.managerDataClass } ];
						
					}
		}
		
		public static function getInstance():Manager
		{
			
			if (this._mng == null)
			{
				
				this._mng = new Manager();
				
			}
			
			return this._mng;
			
		}
		
		public function get isManager():Boolean
		{
			
			return this._isManager;
			
		}
		
		public function get managerData():Object
		{
			
			if (!isManager)
			{
				
				return null;
				
			}
			
			return this._managerData;
			
		}
		
		public function set managerData(managerDataT:Array):void
		{
			
			managerData = managerDataT;
			
		}
	}
}